<template>
  <el-upload
    class="upload-demo"
    drag
    :action="UploadActionPath"
    multiple
    :headers="{token}"
    name="img"
    :data="168"
    :on-success="handleSucess"
    :on-error="handleError"
  >
    <el-icon class="el-icon--upload"><upload-filled /></el-icon>
    <div class="el-upload__text">
      Drop file here or <em>click to upload</em>
    </div>
    <template #tip>
      <div class="el-upload__tip">
        jpg/png files with a size less than 500kb
      </div>
    </template>
  </el-upload>
</template>

<script setup>
import { UploadActionPath } from "@/api/image";
import { getToken } from "@/composible/cookie";
import { notify } from "@/composible/notify";
const token = getToken();
const emits = defineEmits(["success"]);
function handleSucess(response, uploadFile, uploadFiles)
{
  notify("success", "上传成功");
  emits("success", { response, uploadFile, uploadFiles });
}
function handleError(response, uploadFile, uploadFiles)
{
  notify("error", JSON.parse(response.msg));
}
</script>

<style lang="less" scoped>
</style>